package com.haixiaoke.saas.repository.service.impl;

import com.haixiaoke.saas.repository.mapper.HouseFacilitiesItemMapper;
import com.haixiaoke.saas.repository.pojo.HouseFacilitiesItem;
import com.haixiaoke.saas.repository.service.IHouseFacilitiesItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * 房屋设施价格和状态Service业务层处理
 *
 * @author qixi
 * @date 2023-04-17
 */
@Service
public class HouseFacilitiesItemServiceImpl implements IHouseFacilitiesItemService {
    @Autowired
    private HouseFacilitiesItemMapper houseFacilitiesItemMapper;


    /**
     * 查询房屋设施价格和状态
     *
     * @param facilitiesItemId 房屋设施价格和状态主键
     * @return 房屋设施价格和状态
     */
    @Override
    public HouseFacilitiesItem selectHouseFacilitiesItemByFacilitiesItemId(Long facilitiesItemId) {
        return houseFacilitiesItemMapper.selectHouseFacilitiesItemByFacilitiesItemId(facilitiesItemId);
    }

    /**
     * 查询房屋设施价格和状态列表
     *
     * @param houseFacilitiesItem 房屋设施价格和状态
     * @return 房屋设施价格和状态
     */
    @Override
    public List<HouseFacilitiesItem> selectHouseFacilitiesItemList(HouseFacilitiesItem houseFacilitiesItem) {
        return houseFacilitiesItemMapper.selectHouseFacilitiesItemList(houseFacilitiesItem);
    }

    /**
     * 新增房屋设施价格和状态
     *
     * @param houseFacilitiesItem 房屋设施价格和状态
     * @return 结果
     */
    @Override
    public int insertHouseFacilitiesItem(HouseFacilitiesItem houseFacilitiesItem) {
        houseFacilitiesItem.setCreateTime(new Date());
        return houseFacilitiesItemMapper.insertHouseFacilitiesItem(houseFacilitiesItem);
    }

    /**
     * 批量新增房屋设施价格和状态
     *
     * @param houseFacilitiesItems 房屋设施价格和状态
     * @return 结果
     */
    @Override
    public int insertHouseFacilitiesItemList(List<HouseFacilitiesItem> houseFacilitiesItems) {
        int count = 0;
        for (HouseFacilitiesItem houseFacilitiesItem : houseFacilitiesItems) {
            count += houseFacilitiesItemMapper.insertHouseFacilitiesItem(houseFacilitiesItem);
        }
        return count;
    }

    /**
     * 修改房屋设施价格和状态
     *
     * @param houseFacilitiesItem 房屋设施价格和状态
     * @return 结果
     */
    @Override
    public int updateHouseFacilitiesItem(HouseFacilitiesItem houseFacilitiesItem) {
        houseFacilitiesItem.setUpdateTime(new Date());
        return houseFacilitiesItemMapper.updateHouseFacilitiesItem(houseFacilitiesItem);
    }

    /**
     * 批量删除房屋设施价格和状态
     *
     * @param facilitiesItemIds 需要删除的房屋设施价格和状态主键
     * @return 结果
     */
    @Override
    public int deleteHouseFacilitiesItemByFacilitiesItemIds(Long[] facilitiesItemIds) {
        return houseFacilitiesItemMapper.deleteHouseFacilitiesItemByFacilitiesItemIds(facilitiesItemIds);
    }

    /**
     * 删除房屋设施价格和状态信息
     *
     * @param facilitiesItemId 房屋设施价格和状态主键
     * @return 结果
     */
    @Override
    public int deleteHouseFacilitiesItemByFacilitiesItemId(Long facilitiesItemId) {
        return houseFacilitiesItemMapper.deleteHouseFacilitiesItemByFacilitiesItemId(facilitiesItemId);
    }

    @Override
    public int deleteHouseFacilitiesItemByHouseId(String houseId) {
        return houseFacilitiesItemMapper.deleteHouseFacilitiesItemByHouseId(houseId);
    }

    @Override
    public int updateHouseFacilitiesItemList(List<HouseFacilitiesItem> facilitiesItems) {
        int count = 0;
        for (HouseFacilitiesItem houseFacilitiesItem : facilitiesItems) {
            count += houseFacilitiesItemMapper.updateHouseFacilitiesItem(houseFacilitiesItem);
        }
        return count;
    }

    @Override
    public List<HouseFacilitiesItem> selectHouseFacilitiesItemByHouseId(String houseId) {
        return houseFacilitiesItemMapper.selectHouseFacilitiesItemByHouseId(houseId);
    }
}
